package com.wanbangee.marksystem.service.imp;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wanbangee.marksystem.dao.UAccountDao;
import com.wanbangee.marksystem.entities.UAccount;
import com.wanbangee.marksystem.service.UAccountService;
@Service
public class UAccountServicelmp implements UAccountService {
    
	@Autowired
	private UAccountDao uAccountDao;
	@Override
	public UAccount selectAccountByLoginNameAndLoginPass(String loginName, String loginPass) {
		// TODO Auto-generated method stub
		return uAccountDao.selectAccountByLoginNameAndLoginPass(loginName, loginPass);
	}
	@Override
	public String selectLoginPassByLoginName(String loginName) {
		// TODO Auto-generated method stub
		return uAccountDao.selectLoginPassByLoginName(loginName);
	}
	@Override
	public Integer insertTeacherAccount(UAccount uAccount) {
		// TODO Auto-generated method stub
		uAccountDao.insertTeacherAccount(uAccount);
		
		return uAccount.getAccId();
	}
	@Override
	public Integer updateLoginPassByaccIdAndloginName(Integer accId,String loginName, String newloginPass, String oldloginPass) {
		if(oldloginPass.equals(this.uAccountDao.selectLoginPassByLoginName(loginName))) {
			return this.uAccountDao.updateLoginPassByaccIdAndloginName(accId,loginName, newloginPass, oldloginPass);
		}
		
		return  0;
	
	}


}
